package com.huarui.partner.type;

import java.util.Map;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;

public class PartnerTypeConverter extends DefaultTypeConverter{
	private Logger logger = Logger.getLogger(PartnerTypeConverter.class);
	@Override
	@SuppressWarnings("unchecked")
	public Object convertValue(Map<String, Object> context, Object value, Class toType) {
		if (toType == Integer.class) {
			String[] params = (String[])value;
			int num = 0;
			try{
				num = Integer.parseInt(params[0]);
			} catch(NumberFormatException ne) {
				logger.error("客户表单提交时不能转换成数字类型", ne);
			}
			return num;
		} else if (toType == String.class) {
			String[] params = (String[])value;
			return params[0];
		}
		return super.convertValue(context, value, toType);
	}
}
